package uid.jsf;

import java.util.ArrayList;
import java.util.List;


public class Pagina implements Composite {

	private final String cabecalho = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"xmlns:h=\"http://java.sun.com/jsf/html\"xmlns:f=\"http://java.sun.com/jsf/core\"><h:head></h:head><h:body>";
	private final String rodape = "</h:body></html>";
	protected List<Componente> componentes;

	public Pagina() {
		componentes = new ArrayList<Componente>();
	}

	@Override
	public void adicionarComponente(Componente comp) {
		this.componentes.add(comp);
	}

	@Override
	public List<Componente> getComponentes() {
		return this.componentes;
	}

	public String getJSF() {
		String r = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"
				+ "\n"
				+ "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"
				+ "\n" + "<html xmlns=\"http://www.w3.org/1999/xhtml\"" + "\n"
				+ "xmlns:h=\"http://java.sun.com/jsf/html\"" + "\n"
				+ "xmlns:f=\"http://java.sun.com/jsf/core\">" + "\n"
				+ "<h:head>" + "\n" + "</h:head>" + "\n" + "<h:body>" + "\n";

		for (Componente c : this.componentes) {
			r += c.getJSF() + "\n";
		}

		r += "</h:body>" + "\n" + "</html>";

		return r;
	}
}
